/**************************************************************************
** Qt Creator license header template
**   Special keywords: Programmer 2012/3/20 2012
**   Environment variables: 
**   To protect a percent sign, use '%'.
**************************************************************************/

#ifndef MESHMODEL_H
#define MESHMODEL_H
#include <QString>

#include "meshdefs.h"

class MeshModel
{
public:
    MeshModel();
    struct CleanInfo{///////////////////////////////////////////////////////////////////////
        int dv;//Number of Duplicated Vertices removed.
        int df;//Number of Duplicated faces removed.
        int de;//Number of Duplicated edges removed.
        int uv;//Number of unreferenced vertices removed.
        int nmf;////Number of nonmanifold faces removed.
        int nmv;//Number of nonmanifold vertices removed.
        CleanInfo():dv(0),df(0),de(0),uv(0),nmf(0),nmv(0){}
    };
    struct MeshInfo
    {
        std::string FileName;
        bool hasVNormal;
        bool hasFNormal;
        bool hasVColor;
        bool hasFColor;
        bool hasTexture;
        int vn,fn;
        bool VManifold;
        bool FManifold;
        int count_e,boundary_e,numholes;
        int numcomponents;
        bool Orientable,Oriented;

        MeshInfo(){
            vn = 0;
            fn = 0;
            hasVColor = false;
            hasFColor = false;
            hasFNormal = false;
            hasVNormal = false;
            hasTexture = false;
            VManifold = false;
            FManifold = false;
            count_e = 0;
            boundary_e = 0;
            numholes = 0;
            numcomponents = 0;
            Orientable = false;
            Oriented = false;
        }
    };
    enum RenderMode{SMOOTH=0,POINTS,WIRE,FLATWIRE,HIDDEN,FLAT};
    void render(RenderMode& mode);
    void loadMesh(QString& pathName,QString& msg);

    MyTriMesh& triMesh(){return mesh;}
    void getMeshInfo(QString& infoText/*out*/);
    void cleanMesh(QString& info/*out*/);
private:

    QString fullPathName;
    int load_mask;
    MyTriMesh mesh;
    vcg::GlTrimesh<MyTriMesh> glWrapMesh;

};

#endif // MESHMODEL_H
